package com.egao.trade.service.impl;

import com.egao.common.core.damon.results.PageResult2;
import com.egao.common.core.web.JsonResult;
import com.egao.common.system.entity.User;
//import com.egao.trade.mapper.TradeCartMapper;
import com.egao.trade.entity.TradeCart;
import com.egao.trade.service.TradeCartService;
import org.springframework.stereotype.Service;
import com.egao.trade.biz.TradeCartBiz;
import net.sf.json.JSONObject;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
//import javax.transaction.Transactional;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 外贸商品购物车服务实现类
 * @author : Doman
 * @date : 2022-04-18 16:06:30
 * @version ：1.0
 */
@Service
public class TradeCartServiceImpl /*extends ServiceImpl<TradeCartMapper, TradeCart> */implements TradeCartService {

	@Autowired
	private TradeCartBiz tradeCartBiz;

  @Override
  public JsonResult list(PageResult2<T> page, TradeCart tradeCart, User loginUser)  throws Exception{
    return tradeCartBiz.list(page,tradeCart,loginUser);
  }

  @Override
  public JsonResult list(TradeCart tradeCart, User loginUser) {
    return JsonResult.ok().setData(tradeCartBiz.list(tradeCart,loginUser));
  }

  @Override
  public JsonResult getById(TradeCart tradeCart) {
    return JsonResult.ok().setData(tradeCartBiz.getById(tradeCart));
  }

  @Transactional
  @Override
  public JsonResult save(TradeCart tradeCart, User loginUser) {
    if (tradeCartBiz.save(tradeCart, loginUser)) {
      return JsonResult.ok("添加成功");
    }
    return JsonResult.error("添加失败");
  }

  @Transactional
  @Override
  public JsonResult update(TradeCart tradeCart, User loginUser) {
    if (tradeCartBiz.update(tradeCart, loginUser)) {
      return JsonResult.ok("修改成功");
    }
    return JsonResult.error("修改失败");
  }

  @Transactional
  @Override
  public JsonResult remove(TradeCart tradeCart, User loginUser) {
    if (tradeCartBiz.remove(tradeCart, loginUser)) {
      return JsonResult.ok("删除成功");
    }
    return JsonResult.error("删除失败");
  }

}
